package com.boot.unity.api.modules.training.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.unity.api.modules.training.entity.Coach;

@Mapper
public interface CoachDao {

    @Select("select * from training_coach t where t.id = #{id}")
    Coach getById(Long id);

    @Delete("delete from training_coach where id = #{id}")
    int delete(Long id);

    int update(Coach coach);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into training_coach(inscode, coachnum, name, sex, idcard, mobile, address, photo, fingerprint, drilicence, fstdrilicdate, occupationno, occupationlevel, dripermitted, teachpermitted, employstatus, hiredate, leavedate, createTime, updateTime) values(#{inscode}, #{coachnum}, #{name}, #{sex}, #{idcard}, #{mobile}, #{address}, #{photo}, #{fingerprint}, #{drilicence}, #{fstdrilicdate}, #{occupationno}, #{occupationlevel}, #{dripermitted}, #{teachpermitted}, #{employstatus}, #{hiredate}, #{leavedate}, now(), now())")
    int save(Coach coach);
    
    int count(@Param("params") Map<String, Object> params);

    List<Coach> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    @Select("select * from training_coach where inscode = #{inscode} and coachnum = #{coachnum}")
    Coach getByInscodeAndCoachnum(@Param("inscode") String inscode, @Param("coachnum") String coachnum);

    int updateByInscodeAndCoachnum(Coach coach);

    @Delete("delete from training_coach where coachnum = #{coachnum}")
    int deleteByCoachnum(@Param("coachnum") String coachnum);
}
